# class Solution:
#     def discountPrices(self, sentence: str, discount: int) -> str:
#         for word in sentence.split():
#             if "$" in word and "-" not in word and word[0] == "$":
#                 print(word)
#
#
# sentence = "there are $1 $2 and 5$ candies in the shop"
# discount = 50
# aa = Solution()
# aa.discountPrices(sentence, discount)
import re

content = """
小明上街买菜
买了1斤黄瓜花了8元；
买了2斤葡萄花了13.5元；
买了3斤白菜花了5.4元；
买了16斤白酒花了30元；
"""

for line in content.split('\n'):
    pattern = r"(\d+)斤(.*)花了(\d+(\.\d+)?)元"
    match = re.search(pattern, line)
    if match:
        # print(match.groups())
        print(f"买了{match.group(1)}斤{match.group(2)}花了{float(match.group(3))}元")
        print(f"{match.group(1)}\t{match.group(2)}\t{match.group(3)}")
